/*
 * Copyright (c) 2011, Julien Lamy
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 *
 * Neither the name of the project's author nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

#ifndef fbebc4e1_3bdb_40c0_b2ee_38a1e4993fec
#define fbebc4e1_3bdb_40c0_b2ee_38a1e4993fec

#include <iosfwd>
#include <stdint.h>
#include <vector>

#include "album.h"
#include "artist.h"
#include "config.h"
#include "track.h"

namespace DataSetType
{

enum Type
{
    TRACK_LIST=1,
    PLAYLIST_LIST=2,
    PODCAST_LIST=3,
    ALBUM_LIST=4,
    SMART_PLAYLIST_LIST=5,
    ARTIST_LIST=8,
};

}

class BABELPOD_EXPORT ITunesDataBase
{
public:
    uint32_t header_length;
    uint32_t total_length;
    uint32_t unknown_1;
    uint32_t version_number;
    uint32_t number_of_children;
    uint64_t id;
    uint16_t unknown_2;
    uint32_t unknown_3;
    uint64_t unknown_4;
    uint16_t hashing_scheme;
    char unknown_5[20];
    char language[3];
    uint64_t library_persistent_id;
    uint32_t unknown_6;
    uint32_t unknown_7;
    char obscure_hash[20];
    uint32_t time_zone;
    uint16_t unknown_8;
    char iphone_hash[46];

    std::vector<Track> tracks;
    std::vector<Album> albums;
    std::vector<Artist> artists;

    /** @brief Update the albums list from the tracks list. */
    void update_albums();

    /** @brief Update the artists list from the tracks list. */
    void update_artists();
};

BABELPOD_EXPORT std::istream & operator>>(std::istream & stream, ITunesDataBase & itunes_database);

#endif // fbebc4e1_3bdb_40c0_b2ee_38a1e4993fec
